package cn.yangliu.nacos.oauth2.ex;

import cn.yangliu.nacos.oauth2.config.Oauth2ExceptionSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;

/**
 * The interface O auth exception.
 *
 * @author 问道于盲
 * @date 2019 -12-12
 */
@JsonSerialize(using = Oauth2ExceptionSerializer.class)
public class OAuthException extends OAuth2Exception {

    /**
     * current class instance's member.
     * The Http error code.
     */
    private int httpErrorCode;

    /**
     * Instantiates a new O auth exception.
     * allow any class to create a new instance.
     *
     * @param msg           the msg
     * @param t             the t
     * @param httpErrorCode the http error code
     */
    public OAuthException(String msg, Throwable t,int httpErrorCode) {
        this(msg, t);
        this.httpErrorCode = httpErrorCode;
    }

    /**
     * Instantiates a new O auth exception.
     * allow any class to create a new instance.
     *
     * @param msg the msg
     * @param t   the t
     */
    public OAuthException(String msg, Throwable t) {
        super(msg, t);
    }

    /**
     * current class method for getter.
     * Gets http error code.
     *
     * @return the http error code
     */
    @Override
    public int getHttpErrorCode() {
        return httpErrorCode;
    }
}
